]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
introspect: Introspect screen size
authorJonas Ådahl <jadahl@gmail.com>
Wed, 22 Jul 2020 16:38:22 +0000 (18:38 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Fri, 31 Jul 2020 08:51:12 +0000 (10:51 +0200)
To be used by the screen cast service.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1372

data/dbus-interfaces/org.gnome.Shell.Introspect.xml
js/misc/introspect.js

index d71f2414b23fa0481d5355024f67270d2e80342e..47fd7efdc236767f850841780be5638caa287f80 100644 (file)
     -->
     <property name="AnimationsEnabled" type="b" access="read"/>
 
+    <!--
+       ScreenSize:
+       @short_description: The size of the screen
+
+       Since: 3
+    -->
+    <property name="ScreenSize" type="(ii)" access="read"/>
+
     <property name="version" type="u" access="read"/>
   </interface>
 </node>
index e592fb3cf222b6e18016a9fe7f4c295beaa87bf1..6578e2b76a548f913af176570add985778591a47 100644 (file)
@@ -5,7 +5,7 @@ const INTROSPECT_SCHEMA = 'org.gnome.shell';
 const INTROSPECT_KEY = 'introspect';
 const APP_WHITELIST = ['org.freedesktop.impl.portal.desktop.gtk'];
 
-const INTROSPECT_DBUS_API_VERSION = 2;
+const INTROSPECT_DBUS_API_VERSION = 3;
 
 const { loadInterfaceXML } = imports.misc.fileUtils;
 
@@ -59,6 +59,11 @@ var IntrospectService = class {
         this._settings.connect('notify::enable-animations',
             this._syncAnimationsEnabled.bind(this));
         this._syncAnimationsEnabled();
+
+        const monitorManager = Meta.MonitorManager.get();
+        monitorManager.connect('monitors-changed',
+            this._syncScreenSize.bind(this));
+        this._syncScreenSize();
     }
 
     _isStandaloneApp(app) {
@@ -209,10 +214,28 @@ var IntrospectService = class {
         }
     }
 
+    _syncScreenSize() {
+        const oldScreenWidth = this._screenWidth;
+        const oldScreenHeight = this._screenHeight;
+        this._screenWidth = global.screen_width;
+        this._screenHeight = global.screen_height;
+
+        if (oldScreenWidth !== this._screenWidth ||
+            oldScreenHeight !== this._screenHeight) {
+            const variant = new GLib.Variant('(ii)',
+                [this._screenWidth, this._screenHeight]);
+            this._dbusImpl.emit_property_changed('ScreenSize', variant);
+        }
+    }
+
     get AnimationsEnabled() {
         return this._animationsEnabled;
     }
 
+    get ScreenSize() {
+        return [this._screenWidth, this._screenHeight];
+    }
+
     get version() {
         return INTROSPECT_DBUS_API_VERSION;
     }